package com.financing.platform.dao.impl;

import java.util.List;
import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpProjectTransferHisDao;
import com.financing.platform.dto.FpProjectTransferHisDTO;
import com.financing.platform.util.SqlName;
import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpProjectTransferHis")
public class FpProjectTransferHisDaoImpl extends BaseDaoImpl implements IFpProjectTransferHisDao {
	
	@Override
	public FpProjectTransferHisDTO getFpProjectTransferHis(Integer id) {
		try{
			return (FpProjectTransferHisDTO)this.sqlMapClient.queryForObject(SqlName.fpProjectTransferHis,id);
		} catch (SQLException e) {
			log.error("get fpProjectTransferHis error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpProjectTransferHis(FpProjectTransferHisDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpProjectTransferHis,dto);
		} catch (SQLException e) {
			log.error("add fpProjectTransferHis error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpProjectTransferHis(FpProjectTransferHisDTO dto) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpProjectTransferHis, dto);
		} catch (SQLException e) {
			this.log.error("update fpProjectTransferHis error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpProjectTransferHis(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpProjectTransferHis, id);
		} catch (SQLException e) {
			log.error("del fpProjectTransferHis error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpProjectTransferHisDTO> listFpProjectTransferHis(FpProjectTransferHisDTO dto) {
		try {
			return (List<FpProjectTransferHisDTO>)this.sqlMapClient.queryForList(SqlName.listFpProjectTransferHis, dto);
		} catch (SQLException e) {
			log.error("Query fpProjectTransferHis note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpProjectTransferHis(FpProjectTransferHisDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpProjectTransferHis, dto);
		} catch (SQLException e) {
			log.error("Query fpProjectTransferHis note list error !", e);
			return 0;
		}
	}
	
	public String getUserName(String userID){
		try {
			return (String)this.sqlMapClient.queryForObject(SqlName.fpProjectTransferHisGetUserName, userID);
		} catch (SQLException e) {
			log.error("Query fpProjectTransferHisGetUserName note list error !", e);
			return null;
		}
	}


	@Override
	public String getTransferUserNameByProjectID(FpProjectTransferHisDTO dto) {
		try {
			return (String)this.sqlMapClient.queryForObject(SqlName.getTransferUserNameByProjectID, dto);
		} catch (SQLException e) {
			log.error("Query getTransferUserNameByProjectID note list error !", e);
			return null;
		}
	}
}
